from typing import List
from ..models import Turnout
from ..configs import config_file_mgr

FILE_NAME = "turnouts_config.json"


def load_turnouts() -> List[Turnout]:
    # config_file_mgr
    return config_file_mgr.json_load_with_default(FILE_NAME, [])

def turnouts_from_json(turnouts_data: List[dict]) -> List[Turnout]:
    return [Turnout.from_dict(turnout) for turnout in turnouts_data]

def save_turnouts(turnouts_data: List[Turnout]):
    data = [turnout.to_dict() for turnout in turnouts_data]
    config_file_mgr.json_dump(data, FILE_NAME)
